<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>嵌套分组与不记录分组</title>
  </head>
  <body></body>
  <script>
    let hd = `
    https://www.houdunren.com
    http://houdunwang.com
    https://hdcms.com
    `;
    //(?:)在原子组的?：代表此原子组不记数
    //?表示0|1个
    let reg = /https?:\/\/((?:\w+\.)?\w+\.(?:com|org|cn))/gi;
    // console.dir(hd.match(reg));
    let urls = [];
    while ((res = reg.exec(hd))) {
      urls.push(res[1]);
    }
    console.log(urls);
  </script>
</html>
